#ifndef SEATPARAMETERDIALOG_H
#define SEATPARAMETERDIALOG_H

#include <QDialog>
#include <QTreeWidgetItem>
#include <QListWidgetItem>
#include <QTableWidget>
#include <QComboBox>
#include "../description/device.h"
#include "../description/operation.h"
#include "../description/step.h"
#include "../description/Sequence.h"
#include "../parameter/seatdetection.h"

typedef     enum _tagNodeType{
    SequenceType = 0,
    StepType = 1,
    OperationType = 2,
    Other = 3
}NodeType;

namespace Ui {
class SeatParameterDialog;
}

class SeatParameterDialog : public QDialog
{
    Q_OBJECT

public:
    explicit SeatParameterDialog(QWidget *parent = nullptr);

    explicit SeatParameterDialog(SeatDetection& seatDetection,QWidget *parent = nullptr);

    ~SeatParameterDialog();

    virtual void accept() override;

private:
    NodeType                        m_eCurrentNodeType;

    QVector<QComboBox*>             m_vecCameras;
    QVector<QComboBox*>             m_vecFaces;

private:
    SeatDetection                   m_objSeatDetection;

public:
    SeatDetection&                  GetSeatDetection() {return m_objSeatDetection;}

private:
    void    InitTreeWidget();

    void    InitControls();

    void    InitPageBase();

    void    InitComboBoxDatas();

    void    InitComboBoxAllDeviceDatas();

    void    InitCameraInfoDatas();

    void    InitCamerasTableData();
    void    InitPageCameraInfo();

    void    InitYoloClassesTableData();
    void    InitPageYolo();

    void    InitPagePaddleOCR();

    void    InitDetectingWindowsTableData();
    void    InitDetetingWindow();
    void    InitCameraFaceComboBoxs();
    void    RenewCameraFaceComboBoxs(int nRow);

    void    InitDescriptionDevices();

    void    InitDescriptionSequences();

    void    createCameraRowData(int index,QString strIP,QString strMAC,QString strName,QString strIdentifiers);
    void    updateCameraRowData(int index,QString strIP,QString strMAC,QString strName,QString strIdentifiers);

    void    createDetectingWindowRowData(int index, QString name, int number, QString sex, QDate birthday, QString subject, bool graduate);

    void    SwapRows(QTableWidget *tableWidget, int row1, int row2);
    void    MoveUpRow(QTableWidget *tableWidget);
    void    MoveDownRow(QTableWidget *tableWidget);

private slots:
    void On_Base_ImageSrc_Slots();

    void On_Recoginzer_ModelPath_Slots();

    void On_CurrentDeviceTreeItemChanged_Slots(QTreeWidgetItem *,QTreeWidgetItem *);

    void On_CurrentSequenceTreeItemChanged_Slots(QTreeWidgetItem *,QTreeWidgetItem *);

    void On_CurrentDeviceListItemChanged_Slots(QListWidgetItem*,QListWidgetItem*);

    void onImageWidthTextChanged(const QString &text);

    void onImageHeightTextChanged(const QString &text);

    void onImageChannelTextChanged(const QString &text);

    void onPartWidthTextChanged(const QString &text);

    void onPartHeightTextChanged(const QString &text);

    void onSubwindowRowTextChanged();

    void onSubwindowColumnTextChanged();

    void onSubwindowTotalTextChanged();

    void onRS232DeviceIDTextChanged(const QString &text);

    void onDahengCameraDeviceIDTextChanged(const QString &text);

    void onDahengCameraDeviceIPTextChanged(const QString &text);

    void onCamerasTextChanged(const QString& text);

    void onJakaRobotDeviceIDTextChanged(const QString &text);

    void onJakaRobotDeviceIPTextChanged(const QString &text);

    void onJakaRobotDevicePortTextChanged(const QString &text);

    void onRecognizeDeviceIDTextChanged(const QString &text);

    //void onRecognizeDeviceModelPathTextChanged(const QString &text);

    void onRecognizeDeviceUseGPUTextChanged(const QString &text);

    // 串口
    void onSerialPortPortTextChanged(const QString &text);

    void onSerialPortBaudTextChanged(const QString &text);

    void onSerialPortDatabitsTextChanged(const QString &text);

    void onSerialPortStopbitsTextChanged(const QString &text);

    void onSerialPortParityTextChanged(const QString &text);

    void onSerialPortFlowcontrolTextChanged(const QString &text);

    void onDelayDurationTextChanged(const QString &text);

    void onLEDChannelTextChanged(const QString &text);

    void onLEDValueTextChanged(const QString &text);

    void onJoint1TextChanged(const QString &text);

    void onJoint2TextChanged(const QString &text);

    void onJoint3TextChanged(const QString &text);

    void onJoint4TextChanged(const QString &text);

    void onJoint5TextChanged(const QString &text);

    void onJoint6TextChanged(const QString &text);

    void onSnapImageTextChanged(const QString &text);

    void onRecognizeImageTextChanged(const QString &text);

    void onStepNumberTextChanged(const QString &text);

    void onLEDDevicesTextChanged(const QString &text);

    void onMovelJointDevicesTextChanged(const QString &text);

    void onSnapDevicesTextChanged(const QString &text);

    void onRecognizeDevicesTextChanged(const QString &text);

    void OnTreeSequenceRightButtonClicked(QTreeWidgetItem* item, int column);

    void on_pushButtonAddCamera_clicked();

    void on_pushButtonDeleteCamera_clicked();

    void on_pushButtonMoveUpCamera_clicked();

    void on_pushButtonMoveDownCamera_clicked();

    void on_pushButtonModifyCamera_clicked();

    void on_pushButtonAddCategory_clicked();

    void on_pushButtonDeleteCategory_clicked();

    void on_pushButtonMoveUpCategory_clicked();

    void on_pushButtonMoveDownCategory_clicked();

    void on_pushButtonModifyCategory_clicked();

    void on_pushButtonAddDevice_clicked();

    void on_pushButtonDeleteDevice_clicked();

    void on_pushButtonAddSquence_clicked();

    void on_pushButtonDeleteSquence_clicked();

private:
    Ui::SeatParameterDialog *ui;

private:
    Device*             m_pCurrentDevice;
    Operation*          m_pCurrentOperation;
    Step*               m_pCurrentStep;
    Sequence*           m_pCurrentSequence;

    int                 m_CurrentRow;
};

#endif // SEATPARAMETERDIALOG_H
